public class Xiancheng {



    public static void main(String[] args) throws InterruptedException {
        System.out.println("Entering main Method");
        Thread thread=new Thread(new Runnable(){

            @Override
            public void run() {
                System.out.println("开始进入run");

                System.out.println("运行名"+Thread.currentThread());

                try {
                    while (true){
                        try {
                            Thread.sleep(500);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                        System.out.println("In run method: woke up again");
                    }

                }finally {
                    System.out.println("Leaving run Method");
                }

            }
        });
        thread.setDaemon(true);
        thread.start();
        Thread.sleep(1000);
        System.out.println("over");
    }



}


class Xiancheng1 implements Runnable{

    @Override
    public void run() {
        System.out.println("这是一个守护线程");
    }
}